package org.saxonextensions.eml.emitter;

import javax.xml.transform.stream.StreamResult;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.io.Writer;

/**
 * Empty result that always return a random system id and discard any output
 *
 * @author Ivan Latysh
 * @since 2-Apr-2009 5:56:56 PM
 */
public class DevNullResult extends StreamResult {

  protected final OutputStream nullOutputStream = new DevNullOutputStream();

  public DevNullResult() {
    super();
    super.setOutputStream(nullOutputStream);
  }

  public DevNullResult(OutputStream outputStream) {
    super();
    super.setOutputStream(nullOutputStream);
  }

  public DevNullResult(Writer writer) {
    super();
    super.setOutputStream(nullOutputStream);
  }

  public DevNullResult(String systemId) {
    super();
    super.setOutputStream(nullOutputStream);
  }

  public DevNullResult(File f) {
    super();
    super.setOutputStream(nullOutputStream);
  }

  @Override
  public void setOutputStream(OutputStream outputStream) {
    // ignore it
  }

  @Override
  public OutputStream getOutputStream() {
    return nullOutputStream;
  }

  @Override
  public void setWriter(Writer writer) {
    // ignore it
  }

  @Override
  public Writer getWriter() {
    return null;
  }

  public void setSystemId(String systemId) {
    // does nothing
  }

  /**
   * Return string with current time in nanoseconds
   *
   * @return random system id
   */
  public String getSystemId() {
    return String.valueOf(System.nanoTime());
  }
  
}